stylecontext: Move background_is_opaque() function
authorBenjamin Otte <otte@redhat.com>
Thu, 25 Feb 2016 14:40:04 +0000 (15:40 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 25 Feb 2016 15:52:58 +0000 (16:52 +0100)
The new way, it no longer depends on the style context, but on the
CssStyle. This will become relevant in the next commit.

gtk/gtkpixelcache.c
gtk/gtkrenderbackground.c
gtk/gtkrenderbackgroundprivate.h
gtk/gtkstylecontext.c
gtk/gtkstylecontextprivate.h

index dae40447a824bacc9ef4734f0d2a60b3a5d15c13..34a710b6ce8c2a330d8245d9ebf04a30e0a5a9cc 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "gtkdebug.h"
 #include "gtkpixelcacheprivate.h"
+#include "gtkrenderbackgroundprivate.h"
 #include "gtkstylecontextprivate.h"
 
 #define BLOW_CACHE_TIMEOUT_SEC 20
@@ -198,7 +199,7 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache         *cache,
     {
       content = CAIRO_CONTENT_COLOR_ALPHA;
       if (cache->style_context &&
-          _gtk_style_context_is_background_opaque (cache->style_context))
+          gtk_css_style_render_background_is_opaque (gtk_style_context_lookup_style (cache->style_context)))
         content = CAIRO_CONTENT_COLOR;
     }
 
index 5b3591d2984ddfe534920acdc02dced406468b66..a9a80f1636e56401a3d20f2c97f81c20a6849616 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "gtkcssarrayvalueprivate.h"
 #include "gtkcssbgsizevalueprivate.h"
+#include "gtkcsscornervalueprivate.h"
 #include "gtkcssenumvalueprivate.h"
 #include "gtkcssimagevalueprivate.h"
 #include "gtkcssnumbervalueprivate.h"
@@ -344,3 +345,24 @@ gtk_css_style_render_background (GtkCssStyle      *style,
 
   cairo_restore (cr);
 }
+
+static gboolean
+corner_value_is_right_angle (GtkCssValue *value)
+{
+  return _gtk_css_corner_value_get_x (value, 100) <= 0.0 &&
+         _gtk_css_corner_value_get_y (value, 100) <= 0.0;
+}
+
+gboolean
+gtk_css_style_render_background_is_opaque (GtkCssStyle *style)
+{
+  const GdkRGBA *color;
+
+  color = _gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
+
+  return color->alpha >= 1.0
+      && corner_value_is_right_angle (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS))
+      && corner_value_is_right_angle (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS))
+      && corner_value_is_right_angle (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS))
+      && corner_value_is_right_angle (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS));
+}
index b893b69397b782b8aeaa7cad4eae83892795f26e..52a6ffd6870062dfa9074a9cc1620e0b4dffa874 100644 (file)
 
 G_BEGIN_DECLS
 
-void gtk_css_style_render_background  (GtkCssStyle          *style,
-                                       cairo_t              *cr,
-                                       gdouble               x,
-                                       gdouble               y,
-                                       gdouble               width,
-                                       gdouble               height,
-                                       GtkJunctionSides      junction);
+void            gtk_css_style_render_background                 (GtkCssStyle          *style,
+                                                                 cairo_t              *cr,
+                                                                 gdouble               x,
+                                                                 gdouble               y,
+                                                                 gdouble               width,
+                                                                 gdouble               height,
+                                                                 GtkJunctionSides      junction);
+gboolean        gtk_css_style_render_background_is_opaque       (GtkCssStyle          *style);
+
 
 G_END_DECLS
 
index bfb094838bfae7f5cfe6b4029fe6991f792f2316..ed1ad917bb249aee644470068086239ffa5e7f9a 100644 (file)
@@ -27,7 +27,6 @@
 #include "gtkcontainerprivate.h"
 #include "gtkcssanimatedstyleprivate.h"
 #include "gtkcsscolorvalueprivate.h"
-#include "gtkcsscornervalueprivate.h"
 #include "gtkcssenumvalueprivate.h"
 #include "gtkcssimagevalueprivate.h"
 #include "gtkcssnodedeclarationprivate.h"
@@ -45,6 +44,7 @@
 #include "gtkdebug.h"
 #include "gtkintl.h"
 #include "gtkprivate.h"
+#include "gtkrenderbackgroundprivate.h"
 #include "gtkrendericonprivate.h"
 #include "gtksettings.h"
 #include "gtksettingsprivate.h"
@@ -2435,13 +2435,6 @@ gtk_style_context_invalidate (GtkStyleContext *context)
   gtk_style_context_validate (context, NULL);
 }
 
-static gboolean
-corner_value_is_right_angle (GtkCssValue *value)
-{
-  return _gtk_css_corner_value_get_x (value, 100) <= 0.0 &&
-         _gtk_css_corner_value_get_y (value, 100) <= 0.0;
-}
-
 /**
  * gtk_style_context_set_background:
  * @context: a #GtkStyleContext
@@ -2460,8 +2453,6 @@ void
 gtk_style_context_set_background (GtkStyleContext *context,
                                   GdkWindow       *window)
 {
-  const GdkRGBA *color;
-
   g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
   g_return_if_fail (GDK_IS_WINDOW (window));
 
@@ -2473,10 +2464,12 @@ gtk_style_context_set_background (GtkStyleContext *context,
    *
    * We could indeed just set black instead of the color we have.
    */
-  color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
-
-  if (_gtk_style_context_is_background_opaque (context))
+  if (gtk_css_style_render_background_is_opaque (gtk_style_context_lookup_style (context)))
     {
+      const GdkRGBA *color;
+
+      color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
+
       gdk_window_set_background_rgba (window, color);
     }
   else
@@ -3188,22 +3181,6 @@ gtk_gradient_resolve_for_context (GtkGradient     *gradient,
                                      priv->parent ? gtk_style_context_lookup_style (priv->parent) : NULL);
 }
 
-gboolean
-_gtk_style_context_is_background_opaque (GtkStyleContext *context)
-{
-  const GdkRGBA *color;
-
-  g_return_val_if_fail (context != NULL, FALSE);
-
-  color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
-
-  return (color->alpha >= 1.0 &&
-          corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS)) &&
-          corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS)) &&
-          corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS)) &&
-          corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS)));
-}
-
 /**
  * GtkStyleContextPrintFlags:
  * @GTK_STYLE_CONTEXT_PRINT_RECURSE: Print the entire tree of
index 91ce297cd4d52bab367ca9d758150cf36752914e..421e5263fc57bf2c1186b98c2be077a0dd777365 100644 (file)
@@ -70,8 +70,6 @@ void           _gtk_style_context_get_icon_extents           (GtkStyleContext
                                                               gint                width,
                                                               gint                height);
 
-gboolean       _gtk_style_context_is_background_opaque       (GtkStyleContext *context);
-
 PangoAttrList *_gtk_style_context_get_pango_attributes       (GtkStyleContext *context);
 
 /* Accessibility support */